package com.kinghunt.misp.web.context;

import com.kinghunt.misp.common.dto.userx.UserDTO;
import com.kinghunt.misp.service.api.userx.UserReadService;
import com.bygoodtech.kings.common.utils.Checker;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SystemContext {
    private static UserReadService userReadService;

    SystemContext(UserReadService userReadService) {
        this.userReadService = userReadService;
    }

    public static UserDTO getCurrentUser() {
        Long userId = ApiContext.apiUser().getUserId();
        UserDTO user = Checker.success(userReadService.getUserById(userId));
        return user;
    }

    public static UserDTO getCurrentUser4Test() {
        Long userId = 1L;
        UserDTO user = Checker.success(userReadService.getUserById(userId));
        return user;
    }
}
